package com.lg.java.design;

import java.io.Serializable;
import java.lang.reflect.Constructor;

public class Attack1 implements Serializable {
    private static Attack1 instance = new Attack1();
    private Attack1 (){}
    public static Attack1 getInstance() {
    	return instance;  
    }  

    public static void main(String[] args) throws Exception {
        Attack1 s = Attack1.getInstance();

        // 拿到所有的构造函数，包括非public的
        Constructor<Attack1> constructor = Attack1.class.getDeclaredConstructor();
        constructor.setAccessible(true);
        // 使用空构造函数new一个实例。即使它是private的~~~
        Attack1 sReflection = constructor.newInstance();

        System.out.println(s); //com.fsx.bean.Singleton@1f32e575
        System.out.println(sReflection); //com.fsx.bean.Singleton@279f2327
        System.out.println(s == sReflection); // false
    }

}